package frames.kits;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

@Component
public class MainFrame extends JFrame {

    @Autowired
    private FirstButton firstButton;
    @Autowired
    private TextConsole textConsole;
    @Autowired
    private Datas datas;
    @Autowired
    private BoomButtonListener listener;
    public MainFrame(){
        super();
    }
    @PostConstruct
    public void init() {

        this.setTitle("ok");
        this.setSize(800,600);
        this.setLayout(null);
        firstButton.setBounds(100,1,100,30);
        this.add(firstButton);
        JPanel boomSquare = new JPanel();
        boomSquare.setSize(720,540);
        boomSquare.setBounds(40,40,720,540);
        boomSquare.setLayout(new GridLayout(datas.getRow(),datas.getCol()));
        boomSquare.setBackground(new Color(100,55,0));


//                var1.addMouseListener(listener);
//                var1.setBounds(i*10,i*10,12,8);
        Integer[][] mat = datas.getMat();
        for (int i = 0; i <mat.length; i++) {
            for (int j = 0; j < mat[i].length; j++) {
                JButton var1 = new BoomButton(i,j,"p:" + i + "," + j);

                var1.addMouseListener(listener);
                boomSquare.add(var1);
            }
        }
//        this.add(textConsole);
//        this.setLayout(new FlowLayout());
//        this.add(firstButton);


//        textConsole.debug("启动中。。。");
        this.add(boomSquare);
        this.setVisible(true);
    }

}
